package section_06.regularExpression;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestRegularExpression {

	public static String strs[] = { "abcabcabcdefabc", "abc+", "(abc)+", "(abc){2,}" };

	public static void main(String[] args) {

		System.out.println("Input: \"" + strs[0] + "\"");
		for (String arg : strs) {
			System.out.println("Regular expression: \"" + arg + "\"");
			Pattern p = Pattern.compile(arg);
			Matcher m = p.matcher(strs[0]);
			while (m.find())
				System.out.println("Match \"" + m.group() + "\" at positions " + m.start() + "-" + (m.end() - 1));
		}

	}

}
